////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// This file is a part of PMCG project. PMCG is the acronym of Physical       //
// Methods in Computer Graphics.                                              //
//                                                                            //
// Classical algorithms in computer graphics use discrete objects in 3D space //
// like vectors, matrices, triangles, planes. Physical way use an  analytical //
// objects like function, scalar and vector fields. Physical way gives new    //
// look to classical algorithms and allows to overcome some difficulties of   //
// pure geometric methods.                                                    //
//                                                                            //
// Project site:                                                              //
//     http://code.google.com/p/pmcg/                                         //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

#include <exception>

#include "Log.h"
#include "ErrorCodes.h"
#include "TriMesh.h"
#include "IOTriMesh.h"
#include "BBox.h"
#include "GeometryAlgs.h"

using namespace std;

int main(int argc, char *argv[])
{
    if (argc < 2)
    {
        PrintHelp();
        return  PINGP_IVALID_ARGS;
    }

    TriMesh mesh;
    try
    {
        ReadFromObj(argv[1], mesh);
    }
    catch (const exception & e)
    {
       Log("Error: Cannot read mesh from file.");
       return PINGP_IO_ERROR;
    };

    Vector3D v = BBox(mesh).GetRandomPoint();

    if (IsPointInPolyhedron(mesh, v))
        Log("Random bounding box point is in polyhedron");
    else
        Log("Random bounding box point is not in polyhedron");

    return PINGP_OK;
}
